﻿#region Imports
using System;
using System.Windows.Media;
using CommonUtilities.Util;
#endregion Imports

namespace MineSweeper.Models
{
    public class Block : BaseViewModel
    {
        #region Properties
        private int _Id;
        public int Id
        {
            get { return _Id; }
            set { _Id = value; RaisePropertyChanged("Id"); }
        }

        private int _RowId;
        public int RowId
        {
            get { return _RowId; }
            set { _RowId = value; RaisePropertyChanged("RowId"); }
        }

        private int _ColumnId;
        public int ColumnId
        {
            get { return _ColumnId; }
            set { _ColumnId = value; RaisePropertyChanged("ColumnId"); }
        }

        private bool _IsMine;
        public bool IsMine
        {
            get { return _IsMine; }
            set { _IsMine = value; RaisePropertyChanged("IsMine"); }
        }

        public int Left { get; set; }
        public int Top { get; set; }
        public int Right { get; set; }
        public int Bottom { get; set; }

        public int DiagLT { get; set; }
        public int DiagRT { get; set; }
        public int DiagRB { get; set; }
        public int DiagLB { get; set; }

        public int AdjMineCount { get; set; }

        private bool _IsEnabled;
        public bool IsEnabled
        {
            get { return _IsEnabled; }
            set { _IsEnabled = value; RaisePropertyChanged("IsEnabled"); }
        }

        private Brush _BlockBackground;
        public Brush BlockBackground
        {
            get { return _BlockBackground; }
            set { _BlockBackground = value; RaisePropertyChanged("BlockBackground"); }
        }

        private bool _MarkedBomb;
        public bool MarkedBomb
        {
            get { return _MarkedBomb; }
            set { _MarkedBomb = value; RaisePropertyChanged("MarkedBomb"); }
        }

        private bool _MarkedSafe;
        public bool MarkedSafe
        {
            get { return _MarkedSafe; }
            set { _MarkedSafe = value; RaisePropertyChanged("MarkedSafe"); }
        }
        #endregion Properties

        #region Constructors
        public Block()
        {
            IsEnabled = true;
            BlockBackground = Brushes.LightGray;
        }
        #endregion Constructors

        #region Methods
        public override string ToString()
        {
            return String.Format("{12}:{0},{1},{2}\r\n{3},{4},{5},{6}\r\n{7},{8},{9},{10}\r\n{11}",
                RowId, ColumnId, IsMine ? "[X]" : "",
                Left, Top, Right, Bottom,
                DiagLT, DiagRT, DiagRB, DiagLB,
                AdjMineCount, Id);
        }
        #endregion Methods
    }
}
